package cn.xfdzx.android.apps.shop.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.luck.picture.lib.tools.ToastUtils;

import java.util.ArrayList;
import java.util.List;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.bean.OrderDetailInfoBeen;
import cn.xfdzx.android.apps.shop.bean.OrderProcessBeen;
import cn.xfdzx.android.apps.shop.util.ImageGlideUtil;

/**
 * Creator: zf.
 * Date: 2020/9/25.
 * Description:售后服务进度适配器.
 */
public class AfterServiceProcessListAdapter extends BaseQuickAdapter<OrderProcessBeen.DataBean.ProgressBean, BaseViewHolder>  {
    private List<OrderProcessBeen.DataBean.ProgressBean> processinfo = new ArrayList<>();//商品列表
    private String type = "0";//0-零售1-批发
    public AfterServiceProcessListAdapter(@Nullable List<OrderProcessBeen.DataBean.ProgressBean> data) {
        super(R.layout.item_afterserviceinfo, data);
        this.processinfo = data;
    }

    @Override
    public void setData(int index, @NonNull OrderProcessBeen.DataBean.ProgressBean data) {
        super.setData(index, data);
    }


    @Override
    protected void convert(final BaseViewHolder viewHolder, final OrderProcessBeen.DataBean.ProgressBean date) {
        TextView viewcirclebottom = viewHolder.getView(R.id.viewcirclebottom);
        ImageView imgcircle = viewHolder.getView(R.id.imgcircle);
        View viewcircle = viewHolder.getView(R.id.viewcircle);

        if (processinfo.size()>1){
            if (viewHolder.getLayoutPosition() == 0){
                imgcircle.setVisibility(View.VISIBLE);
                viewcircle.setVisibility(View.GONE);
                viewcirclebottom.setVisibility(View.VISIBLE);
            }else if (viewHolder.getLayoutPosition() == processinfo.size()-1){
                imgcircle.setVisibility(View.GONE);
                viewcircle.setVisibility(View.VISIBLE);
                viewcirclebottom.setVisibility(View.GONE);
            }else {
                imgcircle.setVisibility(View.GONE);
                viewcircle.setVisibility(View.VISIBLE);
                viewcirclebottom.setVisibility(View.VISIBLE);
            }
            imgcircle.setImageResource(R.drawable.ic_serviceyesyellow);
        }else {

        }
        viewHolder.setText(R.id.tv_state,date.getMsg())
                .setText(R.id.tv_statedes,date.getEstimateMsg()==null?"":date.getEstimateMsg())
                .setText(R.id.tv_time,date.getTime());


    }
    public void clearDatas(){
        mData.clear();
        notifyDataSetChanged();
    }
    public void refreshDatas(List<OrderProcessBeen.DataBean.ProgressBean> list){
        this.processinfo = list;
        super.replaceData(list);
    }

}
